//
//  IlibJHStat.m
//  IlibJHStat
//
//  Created by Ryan on 15/11/29.
//  Copyright © 2015年 lihongdan. All rights reserved.
//

#import "IlibJHStat.h"

#import <CommonCrypto/CommonDigest.h>

@implementation IlibJHStat

+ (NSString *)strMd5encrypt:(NSString *)str{
    if(!str || str.length==0) return nil;
    NSString *seed=[str stringByAppendingString:@"JHKJYXGS"];
    return [self md5ForKey:seed];
}

+ (NSString *)md5ForKey:(NSString *)seed{
    const char *str = [seed UTF8String];
    unsigned char r[CC_MD5_DIGEST_LENGTH];
    CC_MD5(str, (CC_LONG)strlen(str), r);
    NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
                          r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]];
    return filename;
}

@end
